﻿using System.Windows.Input;
using TestBat.IModels.Domain;
using TestBat.IModels.Models;
using TestBat.IViewModels.Workspaces.Gradings;
using TestBat.ViewModels.Base;
using TestBat.ViewModels.Base.Commands;

namespace TestBat.ViewModels.Workspaces.Gradings
{
    public class GradingViewModel : ViewModel, IGradingViewModel
    {
        public GradingViewModel(ITestTask testTask, ITestTaskModel testTaskModel)
        {
            this.testTask = testTask;
            this.testTaskModel = testTaskModel;
        }

        public ISolution Solution
        {
            get
            {
                return testTask.Solution;
            }
        }

        public ITestTask Task
        {
            get
            {
                return testTask;
            }
        }

        public ICommand MarkCorrectCommand
        {
            get
            {
                return new RelayCommand(c =>
                    {
                        testTaskModel.Grade(testTask, 100);
                    });
            }
        }

        public ICommand MarkIncorrectCommand
        {
            get
            {
                return new RelayCommand(c =>
                {
                    testTaskModel.Grade(testTask, 0);
                });
            }
        }

        private readonly ITestTask testTask;
        private readonly ITestTaskModel testTaskModel;
    }
}
